﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Util
{
    public class MD5Encryptor
    {
        /// <summary>
        /// MD5 Encryptor
        /// </summary>
        /// <param name="plaintext"></param>
        /// <returns>Base64 string</returns>
        public static string PlaintextToMD5Base64(string plaintext)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider MD5CSP = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] MD5Source = System.Text.Encoding.UTF8.GetBytes(plaintext);
            byte[] MD5Out = MD5CSP.ComputeHash(MD5Source);

            return Convert.ToBase64String(MD5Out);
        }
    }
}
